package com.opencloud.iot.provider.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.opencloud.common.model.PageParams;
import com.opencloud.common.model.ResultBody;
import com.opencloud.iot.client.model.entity.IotNStreng;
import com.opencloud.iot.client.model.entity.IotStreng;
import com.opencloud.iot.provider.service.IotNStrengService;
import com.opencloud.iot.provider.service.IotStrengService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 物联设备（手环）信息
 * @author yeyong
 */
@RestController
@Api(value = "物联网设备", tags = "物联网设备（手环）动量查看")
public class IotNStrengController {
    @Autowired
    private IotNStrengService iotNStrengService;

    /**
     * 获取手环动量分页信息
     * @param map
     * @return
     */
    @ApiOperation(value = "获取手环动量分页信息", notes = "获取手环动量分页信息")
    @GetMapping("/nstreng/infos")
    public ResultBody<IPage<IotNStreng>> getNStrengListPage(
            @RequestParam(required = false) Map map,
            @RequestParam(value = "startTime",required = false) Long startTime,
            @RequestParam(value = "endTime",required = false) Long endTime
    )
    {
        return ResultBody.ok().data(iotNStrengService.findListPage(new PageParams(map),startTime,endTime));
    }


    /**
     * 获取手环动量分页信息
     * @return
     */
    @ApiOperation(value = "获取手环动量信息", notes = "获取手环动量信息")
    @GetMapping("/api_nstreng/list")
    public List<IotNStreng> getNStrengList(
            @RequestParam(value = "startTime",required = false) Long startTime,
            @RequestParam(value = "endTime",required = false) Long endTime,
            @RequestParam(value = "watchmac",required = false) String watchmac
    )
    {
        return iotNStrengService.findList(startTime,endTime,watchmac);
    }
}
